package bio.three;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/*
    实现伪异步IO通信
 */
public class Server {
    public static void main(String[] args) {
        try {
            ServerSocket serverSocket = new ServerSocket(9999);
            //创建线程池
            HandlerSocketPoll handlerSocketPoll = new HandlerSocketPoll(5, 10);
            while (true) {
                //监听客户端socket
                Socket socket = serverSocket.accept();
                //将服务端的socket封装为Runnable对象
                SocketTask task = new SocketTask(socket);
                //提交任务
                handlerSocketPoll.commitTask(task);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
